﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.IService.System;
using SmartAnswerPlatform.Models.Entitys.System;
using SmartAnswerPlatform.Models.RequestModels;
using SmartAnswerPlatform.Models.ViewModels.System;

namespace SmartAnswerPlatform.WebApi.Controllers.System
{
    [Route("role")]
    public class SysRoleController : BaseController
    {
        private readonly ISysRoleService _sysRoleService;

        public SysRoleController(ISysRoleService sysRoleService)
        {
            _sysRoleService = sysRoleService;
        }

        [HttpPost("findAll")]
        public async Task<ActionResult> FindAll()
        {
            return Success(await _sysRoleService.FindAll());
        }

        [HttpPost("add")]
        public async Task<ActionResult> Add([FromBody] SysRoleViewModel menuViewModel)
        {
            return Success(await _sysRoleService.Insert(menuViewModel));
        }

        [HttpPost("update")]
        public async Task<ActionResult> update([FromBody] SysRoleViewModel menuViewModel)
        {
            return Success(await _sysRoleService.Update(menuViewModel));
        }

        [HttpPost("delete")]
        public async Task<ActionResult> delete([FromBody] IdRequestModels idRequest)
        {
            return Success(await _sysRoleService.Delete(idRequest.Id));
        }
    }
}
